#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
func(int k)
{
	return k & (k + 1);
}

int
main(int argc, char **argv)
{
	register int i=0, j=0;
	int n_cols = 0;
	char map[256+128][256+128]; /* 64K is enough for everyone */

	if (argc <= 1) {
		(void) printf("i can haz 1 integer argument?\n");
		return 0;
	}

	memset(map, ' ', sizeof map);
	n_cols = atoi(argv[1]);
	for (i = 0 ; i <= n_cols ; ++i) {
		for (j = i ; j >= 0 && j >= func(i) ; --j)
			map[j][i] = '*';
	}
	for (i = n_cols ; i >= 0 ; --i) {
		(void) printf("%4d |", i);
		for (j = 0 ; j <= n_cols ; ++j)
			putchar(map[i][j]);
		putchar('\n');
	}
	fputs("-----+", stdout);
	for (j = 1 ; j <= n_cols ; ++j)
		putchar('-');
	putchar('\n');
	fputs("     |", stdout);
	for (j = 0 ; j <= n_cols ; ++j)
		(void) printf("%d", j % 10);
	putchar('\n');

	return 0;
}
